var fs = require("fs");

exports.read = function (filePath, callback) {
	fs.readFile(filePath, function(error, file) {
		callback(file);
	});
}

exports.find = function (dir, filename, callback) {
  fs.readdir(dir, function(err, list) {
		
    list.forEach(function(file) {
			
      var filePath = dir + "/" + file;
      fs.stat(filePath, function(err, stat) {
				
        if (stat && stat.isDirectory()) {
          exports.find(filePath, filename, function(err, res) {
            	if (!err)
								callback(false, res);
          });
        } else {
          if (file == filename) {
						callback(false, filePath);
					}
        }
      });
    });
  });
}
